<?php

if (!isset($GET)) {
    $MDRC = $_POST['MDRC'];
    $GET[1]['BnfCedula'] = '';
    $GET[1]['BnfDocType'] = '';
    $GET[1]['BnfPais'] = $_POST['BnfPais'];
    if (isset($_POST['BnfDocType'])) { $GET[1]['BnfDocType'] = $_POST['BnfDocType']; }
    echo '<script charset="utf-8" type="text/javascript">';
    include($GLOBALS['BIB'] . 'ValScripts/doc_' . $_POST['BnfDocType'] . '.mex');
    echo '</script>'.rt_field('hidden', 'ED', 'ctrl', '', '', '', '', '');
}
$DocTypes = "SELECT tdc_Id AS ID, tdc_Tipo AS NAME FROM hd_documentostipos
WHERE Country_ID = {$GET[1]['BnfPais']} AND tdc_Activo = 1";
echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>'.rt_field('select', $MDRC, 'BnfDocType', $GET[1]['BnfDocType'], $DocTypes, '', '', '"
		onchange="document.ReceiverProperties.action=\'_response/call.php?get=Operative/view/viewreceiverdocument\';
		subform(\'ReceiverProperties\',\'DocVal\');');
if ($GET[1]['BnfDocType'] == 7 || $GET[1]['BnfDocType'] == '' || $GET[1]['BnfDocType'] == 0) {
    echo '</td><td width="100%">'.rt_field('text', $MDRC, 'BnfCedula', $GET[1]['BnfCedula'], '14', '13', 'True', '"
			onKeyUp="if(ValDoc(document.ReceiverProperties.BnfCedula.value)==false) {
				document.ReceiverProperties.PRSVRC.disabled=true;
				document.getElementById(\'rsValMsg\').style.display=\'none\';
				document.getElementById(\'rsInValMsg\').style.display=\'\';
				} else {
				document.ReceiverProperties.PRSVRC.disabled=false;
				document.getElementById(\'rsValMsg\').style.display=\'\';
				document.getElementById(\'rsInValMsg\').style.display=\'none\';
				setTimeout(fJS_Formata(ReceiverProperties,this.name,11,8,5,0,2,event),1000);
				}');
} elseif ($GET[1]['BnfDocType'] == 8) {
    echo '</td><td width="100%">'.rt_field('text', $MDRC, 'BnfCedula', $GET[1]['BnfCedula'], '18', '17', 'True', '"
			onKeyUp="if(document.ReceiverProperties.BnfCedula.value.length>=14 && document.ReceiverProperties.ctrl.value == \'\') {
			document.ReceiverProperties.ctrl.value=1;
			if(ValCNPJ(document.ReceiverProperties.BnfCedula.value)==true) {
				document.ReceiverProperties.PRSVRC.disabled=false;
				document.getElementById(\'rsValMsg\').style.display=\'\';
				document.getElementById(\'rsInValMsg\').style.display=\'none\';
				setTimeout(fJS_Formata(ReceiverProperties,this.name,14,12,9,6,2,event),1000);
			} else {
				document.ReceiverProperties.PRSVRC.disabled=true;
				document.getElementById(\'rsValMsg\').style.display=\'none\';
				document.getElementById(\'rsInValMsg\').style.display=\'\';
			}
			} else {
				document.ReceiverProperties.PRSVRC.disabled=true;
				document.ReceiverProperties.ctrl.value=\'\';
				document.getElementById(\'rsValMsg\').style.display=\'none\';
				document.getElementById(\'rsInValMsg\').style.display=\'\';
			}');
}
echo '</td>
    <td><div style="display:none" class="Confirm" id="rsValMsg">{basic_valid}</div>
	<div style="display:none" class="Error" id="rsInValMsg">{basic_invalid}</div></td>
  </tr>
</table>';